#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "include/lh_nonstandard_485_drive.h"
#include "include/lhmodbuslib.h"
#include "qthread.h"
#include <QMainWindow>
#include <QModbusClient>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    MainWindow( QWidget* parent = nullptr );
    ~MainWindow();
    void comList();

private slots:
    /*******************************************/
    void sltModbusBack( const QString& key, const QModbusDataUnit readData, const QString& info );
    /*******************************************/

    /*******************************************/
    void sltTransmissionError( const uchar deviceAddress );
    void sltTransmissionState( const TransmissionInter::TransMissionData data );
    void sltErrorinfo( const LH_NonStandard_485_Drive::DriveErrorState driveErrorState, const QString info );
    /*******************************************/
    void on_comboBox_2_currentTextChanged( const QString& arg1 );

    void on_comboBox_currentTextChanged( const QString& arg1 );

    void on_send_string_clicked();

    void on_send_int_clicked();

    void on_comboBox_4_currentIndexChanged( int index );

    void on_comboBox_3_currentIndexChanged( int index );

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_5_clicked();

    void on_comboBox_5_currentTextChanged( const QString& arg1 );

    void on_pushButton_4_clicked();

    void on_pushButton_6_clicked();

private:
    void onInitLHModbusLib();
    void onInitLHNonStandardLib();
    void onInitLHBatter();
    void onNamespaceTest();

private:
    Ui::MainWindow* ui;
    /********************LHmodbus**************************/
    QThread*     thread = nullptr;
    QString      string_key;
    QString      string_list_key;
    QString      int_key;
    LHModbusLib* lhModbusLib;
    /********************LHmodbus**************************/
    /********************LHNonStandard**************************/
    QThread*                            thread_non = nullptr;
    int                                 control_stat_ID;
    TransmissionInter::TransMissionData transMissionData;
    LH_NonStandard_485_Drive*           nonStandard_485_drive;
    QThread*                            thread_batter = nullptr;
    LH_NonStandard_485_Drive*           batter;
    /********************LHNonStandard**************************/
};
#endif  // MAINWINDOW_H
